Repository navigation
Conversation
[High impact] Shared providers and custom image models affect agent and image workflows across an instance. Fix the lost connection retries before merging; also mask endpoint errors before shortening them. FindingsSummaryAdds image models to personal and shared custom providers.
Acknowledged limits:
|
| const Class = ERROR_CLASSES.find((candidate) => error instanceof candidate) ?? Error | ||
| return new Class(message) |
There was a problem hiding this comment.
Dropped connections no longer retry
redactedError drops the error's code and cause, which isInterruptedModelTurn uses to recognize a dropped connection. When a custom provider's request fails with ECONNRESET or UND_ERR_SOCKET, the wrapper turns it into a plain Error. retryModelTurn then stops the run instead of retrying it. Preserve the retry signal without keeping secret-bearing error details.
| const detail = typeof body?.error === 'string' ? body.error : body?.error?.message | ||
| throw new Error( | ||
| detail | ||
| ? `${config.name} did not generate an image: ${detail.slice(0, 300)}` |
There was a problem hiding this comment.
Errors can expose shortened secrets
drawCustom shortens error.message before redactedImageError masks secrets. If an endpoint quotes the shared key across character 300, the shortened key no longer matches redactSecrets, so its prefix reaches the caller unchanged. HTTP error bodies have the same problem at the 400-character limit in responseError. Mask the full text before shortening it, and cover both boundaries in tests.
How this was verified: Both error paths shorten endpoint text before exact-value masking, and the MCP tool returns the resulting message to the caller.
|
@gganebnyi this is a sick PR, can you check on the greptile comments and then we can get that in. |
|
Sure, will do tomorrow |
An instance admin adds a custom provider once (any OpenAI Chat Completions or Anthropic Messages endpoint) and every signed-in person gets it beside their own connections. The definition, key and headers live in shared_model_accounts (key and headers sealed); each person's model, effort and on/off live in shared_model_account_prefs (migration 0062). getAccounts/getAccount merge the enabled ones after the person's own accounts as accounts marked shared, so the composer, the default (someone with no account of their own runs on the first one on), the free-tier meter and runs need no change. Picks write the person's prefs row; edit and disconnect of a shared kind are refused with 403, and the set-up probes never fall back to a shared key. A person sees the endpoint's origin only. DOOP_CUSTOM_PROVIDERS=false hides them. Admin routes under /api/admin/shared-providers list, add, edit (a key left out is kept), switch on or off, delete (with every person's prefs), and list models or test before saving, through the same validation and probes as personal providers, which move from index.ts to customProviders.ts. No response carries the key or header values, the admin's included, and the stored ones only go to the origin they were saved for: a probe or edit for another origin must bring its own. For billing a shared provider is the person's own connection: it lifts the free-tier meter, and the server's image keys stop drawing for them as for anyone with a connection. Run failures on a shared provider tell the person to ask their admin rather than to reconnect it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ABWHJg7QHZpRjDADALswQZ
Admin → Shared models lists each shared provider (name, API type, host, model count, whether a key is set) with an on/off switch, Edit and Remove, and empty, loading, error and switched-off states. Adding and editing open the custom provider form in admin mode: the same fields, Fetch models and Test, through the admin routes; the key is never shown and blank keeps it. In Settings → Doop Agent a shared provider is a connection row with a "Shared by your admin" badge: its model, switch and Make default work; Edit provider and Disconnect are not offered. The composer names a shared runner "Name (shared)" so it reads apart from a personal provider of the same name. Strings in en and pt-BR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ABWHJg7QHZpRjDADALswQZ
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ABWHJg7QHZpRjDADALswQZ
A Chat Completions custom provider can list image models next to its chat
models (`imageModels: { id, name?, transparent? }[]`, at most 20, in the
same `custom` jsonb, so no migration; descriptions stored before keep
parsing). Whoever has the provider connected and on, an admin's shared
one included, finds them in GET /api/image-model after the registry and
can pick one (stored in image_prefs as `custom:<id>/<model id>`). With no
pick, the first one is the default once nothing on the registry can run,
so a person whose only connection is a shared provider draws on it from
their first sign-in.
generate_image draws through POST {baseUrl}/images/generations over
customProviderFetch (private hosts, DNS pinning, no redirects, size cap)
with the provider's key and headers and imageApiGenerator's body. It reads
data[0].b64_json, or fetches data[0].url the same way, sending the
credentials only to the base URL's origin, and accepts PNG, JPEG or WebP
only. It is billed as the person's own connection; a pick that cannot run
(switched off, deleted, delisted, or custom providers off) refuses with
the fix and never falls back to another model or a server key. A 401/403
on a shared provider tells the person to ask their admin.
Endpoint text that reaches a person or a log (a refusal body, a 429, an
error beside a 200) has the provider's key and header values masked, as
its chat turns do. With no pick, the person's own credentials (registry
accounts, then custom image models) come before anything a server key
pays for, Seedream on ARK_API_KEY included. Disconnecting a personal
provider or deleting a shared one deletes the image-model picks on it.
generate_image (MCP and resident) takes an optional `transparent`: only a
model marked so is sent `background: "transparent"`, and the result says
whether the cut-out was drawn. Analytics get `custom-personal` or
`custom-shared`, never the provider's name.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ABWHJg7QHZpRjDADALswQZ
…e-model list
The custom provider form (Settings and Admin → Shared models) gets an
Image models section under the models, for the Chat Completions API type:
id, optional name, a Transparent switch, remove and Add image model. The
ids Fetch models found are offered for both lists. Admin's shared
provider row counts its image models.
Settings → Doop Agent → Image model lists each custom provider's image
models after the registry, one row per provider ("Name (shared)" for an
admin's), with a dropdown when it lists several. Strings in en and pt-BR.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ABWHJg7QHZpRjDADALswQZ
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ABWHJg7QHZpRjDADALswQZ
d39e23e to
b882ff7
Compare
|
@kgoedecke issues addressed |
Why
generate_imageonly draws with the built-in registry (GPT Image, Nano Banana, Seedream). Teams that self-host animage model behind an OpenAI Images-compatible endpoint (a LiteLLM gateway in front of ComfyUI/FLUX, vLLM, LocalAI) have
no way in:
OPENAI_IMAGES_URLis server-wide, takes registry ids only and runs on an OpenAI key, which since #609 nolonger draws for people who have a shared provider.
What
models:
imageModels: { id, name?, transparent? }[], at most 20. Validated inparseCustomProviderConfig; stored inthe existing
customjsonb, so no migration, and descriptions stored before keep parsing.(one row per provider, "Name (shared)" for a shared one). The pick is stored in
image_prefsascustom:<id>/<model id>. With no pick, the person's own credentials come first (registry accounts, then custom imagemodels) and only then anything a server key pays for (Seedream on
ARK_API_KEYincluded), so someone whose onlyconnection is a shared provider draws on it from their first sign-in. Disconnecting a personal provider or deleting a
shared one deletes the picks on it.
generate_imagedraws throughPOST {baseUrl}/images/generationsovercustomProviderFetch(respectingDOOP_CUSTOM_PROVIDERS/DOOP_CUSTOM_PROVIDER_PRIVATE_HOSTS, DNS pinning, no redirects, size cap) with theprovider's key and headers and the same body as
imageApiGenerator. Readsdata[0].b64_json; adata[0].urlisfetched the same way, with credentials only when it is on the base URL's origin. PNG/JPEG/WebP only.
cannot run (switched off, deleted, delisted, feature off) refuses with the fix — never a fallback to another
model or a server key.
a personal one, "update the key in Settings". 404/unknown model names the model and
/images/generations. Endpointtext (error bodies, 429s, an
error.messagebeside a 200) has the key and header values masked with feat(admin): shared model providers for everyone on the instance #609'sredactSecrets.generate_image(MCP and resident) gains an optionaltransparent; only a model markedtransparentis sentbackground: "transparent", and the result says whether the image drawn actually has transparency (read off theimage, alpha kept in the WebP). The agent guide and the README tool table say so.
CustomProviderForm(Settings and Admin), Chat Completions only; Fetch modelsoffers ids for both lists. Admin's shared row shows the image-model count. Strings in en and pt-BR.
custom-personal/custom-shared(serverbilled_toand the Settings pick event), never theprovider's name or model id.
Spec:
.context/specs/custom-provider-image-models.md(+ INDEX, TECHSTACK,.env.example).Tests
customProvider.test.ts— parsing: normalising, cap, ids, duplicates, names, Anthropic drops them, stored configswithout the field; the preference ref.
customProviderImages.test.ts— request shape, personal and shared draws, default for a shared-only user while serverkeys are set, picker entries, switched-off / deleted / delisted picks refusing without network, URL responses with and
without credentials, non-image answers, error wording, private hosts.
sharedModelAccounts.test.ts— through the realgetAccounts, and gone withDOOP_CUSTOM_PROVIDERS=false.customProviderImagesHttp.test.ts— real server + stub images endpoint: admin adds image models, a non-admin cannotchange them (404 admin routes, 403 personal route), picker lists and picks them, MCP
generate_imagestores the imagedrawn on the shared key, 401 wording, switched-off draws nothing, personal provider path, key in no response.
customProviderForm.test.tsx,imageModelCard.test.tsx— the form section and the picker rows.bun run typecheck✓ ·bun run lint✓ ·bun run test: all green excepttests/serverListen.test.ts(IPv6 on thedev machine, fails on the base branch too).
Manually: dev server + a stub images endpoint — admin added a shared provider with an image model through the Admin
form (Fetch models → image list, Transparent on), a new user saw it checked in Settings → Image model, and MCP
generate_imagewithtransparent: truestored a 1024×1024 WebP billed to the provider; the stub received the sharedkey and
background: "transparent"; no response carried the key.Notes for review
qualityandoutput_formatare GPT Image fields; a strict server that refuses unknown fields will 400. LiteLLM andmost gateways pass or drop them. Happy to add a per-model "plain request" switch if wanted.
would need the agent default and composer to skip providers without chat models — left out on purpose.
🤖 Generated with Claude Code
https://claude.ai/code/session_01ABWHJg7QHZpRjDADALswQZ